FROM golang:1.17.1-alpine AS srv
MAINTAINER author:fzxs8@yeah.net

COPY dns-srv /mnt/dns-srv

WORKDIR /mnt/dns-srv

RUN   sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
      && apk update && apk add \
      g++ \
      gcc \
     && go env -w GO111MODULE=on \
     && go env -w GOPROXY=https://goproxy.cn,direct \
     && go build -o /sbin/dns-srv

RUN ls -l /sbin/

FROM node:16-alpine AS web

COPY dns-web /mnt/dns-web

WORKDIR /mnt/dns-web

COPY build/cmd.sh .

RUN sh cmd.sh 'web'

FROM nginx:1.21-alpine

#RUN   sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
#      && apk update && apk add \
#      bind-tools

COPY --from=srv /sbin/dns-srv /sbin

COPY --from=srv /mnt/dns-srv/it-dns.db /it-dns.db

COPY --from=web /mnt/dns-web/dist /mnt/dist

COPY build/cmd.sh /

COPY ./build/nginx.conf /etc/nginx/nginx.conf

COPY ./build/conf.d/default.conf /etc/nginx/conf.d/default.conf

RUN sh cmd.sh 'copy'

WORKDIR /

EXPOSE 53/udp/tcp
EXPOSE 80
# CMD ["sh", "cmd.sh" ,"run", "&&" , "nginx", "-g", "daemon off;"]
CMD sh cmd.sh run 